package edu.udlap.spring2008.is300.finalexam.framework.mvc.model;

import edu.udlap.spring2008.is300.finalexam.framework.mvc.model.database.filters.ImageRecordFilter;
import edu.udlap.spring2008.is300.finalexam.framework.mvc.model.database.objects.ImageRecord;
import edu.udlap.spring2008.is300.finalexam.framework.mvc.observerobservable.favorites.FavoritesChangedObservable;
import edu.udlap.spring2008.is300.finalexam.framework.mvc.observerobservable.imageset.ImageSetChangedObservable;
import edu.udlap.spring2008.is300.finalexam.framework.mvc.observerobservable.selection.SelectionChangedObservable;

/**
 * This interface is intended to permit access to the state & operations of a
 * model.
 * 
 * This interface is to be used by any modules that should have access to
 * state/operations over the model.
 * 
 * @author Ruslán Ledesma Garza
 */
public interface Model extends
        ModelState,
        ImageSetChangedObservable,
        SelectionChangedObservable,
        FavoritesChangedObservable
{
    /**
     * Initializes the model by perfoming any initialization tasks needed.
     */
    void initialize();
    
    /**
     * Finalizes and stops the model by freeing any resources allocated for it.
     */
    void stop();
    
    /**
     * Adds an image record to the database.
     * 
     * @param imageRecord the image record to be added.
     * @return true if the operation succeeded, false otherwise.
     */
    boolean addImageRecord(ImageRecord imageRecord);
    
    /**
     * Deletes the currently selected image.
     * 
     * @return true if the operation succeeded, false otherwise.
     */
    boolean deleteSelectedImageRecord();
    
    /**
     * Replaces a given image record for another based upon its id.
     * 
     * @param imageRecord the image record that will replace the existing one.
     * @return true if the operation succeeded, false otherwise.
     */
    boolean updateImageRecord(ImageRecord imageRecord);
    
    /**
     * Sets the currently selected image record in the model. This method will
     * succeed  only if the requested image record matches the current image
     * record filter.
     * @param id the id of the image record to be selected.
     * @return true if the operation succeeded, false otherwise.
     */
    boolean setSelectedImageRecord(int id);
    
    /**
     * Sets the image record filter of the model. This affects some of the
     * behavior of the model.
     * @param imageRecordFilter
     * @return true if the operation succeeded, false otherwise.
     */
    boolean setImageRecordFilter(ImageRecordFilter imageRecordFilter);
}
